<template>
  <div class="bankContainer">
    <!-- 面包屑导航 -->
    <el-breadcrumb
      separator-class="el-icon-arrow-right"
      v-show="$route.name !== 'personal'"
      style="padding-left: 0px"
    >
      <el-breadcrumb-item :to="{ name: 'personal' }"
        >个人业务</el-breadcrumb-item
      >
      <el-breadcrumb-item> {{ $route.meta.aliasName }} </el-breadcrumb-item>
    </el-breadcrumb>

    <!--搜索条件区域-->
    <div class="personalSearch" v-show="$route.name === 'personal'">
      <el-row :gutter="20">
        <!--<el-col :span="2">-->
        <!--<div class="grid-content bg-purple searchInputStyle">查询条件：</div>-->
        <!--</el-col>-->
        <el-col :span="20">
          <div class="grid-content bg-purple-light">
            <avue-form
              :option="optionFormData"
              v-model="objForm"
              ref="formPersonal"
              @submit="searchSubmitForm"
            ></avue-form>
          </div>
        </el-col>
        <el-col :span="20">
          <div
            class="grid-content bg-purple"
            style="float: left; padding-bottom: 40px"
          >
            <el-button
              type="primary"
              @click="queryInfo"
              size="large"
              style="width: 100px"
              >查询</el-button
            >
            <el-button
              type="primary"
              @click="restAll"
              size="large"
              style="width: 100px"
              >重置</el-button
            >
          </div>
        </el-col>

        <!-- <el-col :span="3">
          <div class="grid-content bg-purple">
            <el-button type="primary" @click="verificationFn">电话验密</el-button>
          </div>
        </el-col> -->
      </el-row>
    </div>

    <div class="verificationTips">
      <!-- <span
        :class="{
          'el-icon-circle-close': this.idPass,
          'color-red': this.idPass,
          'el-icon-circle-check': !this.idPass,
          'color-green': !this.idPass
        }"
        >
        {{ this.idCheckTxt }}</span> -->
    </div>
    <!-- 基本信息 -->
    <informationShow
      :data="personalInfoData"
      :option="personalOption"
    ></informationShow>
    <!-- 2024-04-14 删除账户信息列表 -->
    <!-- 列表信息 -->
    <!-- <ChildDropDown :data="accountData" :option="accountOption" @checkedListBn="checkedListBn"
                   v-show="$route.name === 'personal'"></ChildDropDown> -->
    <!-- 列表信息展示 只显示选中的 -->
    <!-- <ChildDropDown :data="personalListInfoData" :option="accountOption"
                   v-show="$route.name !== 'personal'"></ChildDropDown> -->
    <!-- 导航菜单栏 -->

    <div style="padding-top: 10px">
      <el-tabs
        type="border-card"
        :before-leave="handleTabChange"
        @tab-click="onhome"
        ref="tabs"
        v-model="activeTab"
      >
        <el-tab-pane name="shouye">
          <span slot="label"><i class="el-icon-date"></i> 首页</span>
          <div class="sonArea mt10" v-show="$route.name === 'personal'">
            <draggable
              v-model="listData"
              @start="drag = true"
              @end="drag = false"
            >
              <div
                class="inlineStyle"
                v-for="(item, index) in listData"
                v-show="item.show"
                :key="index"
                @click="handleIconClick(item.routerName)"
              >
                <!-- <router-link :to="{ name: item.routerName }"> -->
                <div :class="[item.imgClass, 'commonIcon']" alt=""></div>
                <span>{{ item.name }}</span>
                <!-- </router-link> -->
              </div>
            </draggable>
          </div>
          <keep-alive>
            <router-view v-if="$route.meta.keepAlive" />
          </keep-alive>
          <router-view v-if="!$route.meta.keepAlive" />
        </el-tab-pane>

        <el-tab-pane
          label="还款信息查询"
          name="repayPlan"
          v-if="activeTab2.includes('repayPlan')"
        >
          <span slot="label"><i class="el-icon-date"></i> 还款信息查询</span>

          <repayPlan
            :personalInfoData="personalInfoData"
            ref="repayPlan"
          ></repayPlan>
        </el-tab-pane>

        <el-tab-pane
          label="客户资料查询"
          name="customerInfo"
          v-if="activeTab2.includes('customerInfo')"
        >
          <span slot="label"><i class="el-icon-date"></i> 客户资料查询</span>

          <customerInfo
            :personalInfoData="personalInfoData"
            ref="customerInfo"
          ></customerInfo>
        </el-tab-pane>

        <el-tab-pane
          label="客户影像件查看"
          name="customerImageView"
          v-if="activeTab2.includes('customerImageView')"
        >
          <span slot="label"><i class="el-icon-date"></i> 客户影像件查看</span>

          <customerImageView
            :data="personalInfoData"
            ref="customerImageView"
          ></customerImageView>
        </el-tab-pane>

        <el-tab-pane
          label="溢缴款管理"
          name="overPayManage"
          v-if="activeTab2.includes('overPayManage')"
        >
          <span slot="label"><i class="el-icon-date"></i> 溢缴款管理</span>

          <overPayManage
            :data="personalInfoData"
            ref="overPayManage"
          ></overPayManage>
        </el-tab-pane>

        <el-tab-pane
          label="主动还款"
          name="proactiveRepayment"
          v-if="activeTab2.includes('proactiveRepayment')"
        >
          <span slot="label"><i class="el-icon-date"></i> 主动还款</span>

          <proactiveRepayment
            :data="personalInfoData"
            ref="proactiveRepayment"
          ></proactiveRepayment>
        </el-tab-pane>

        <el-tab-pane
          label="额度协议管理"
          name="quotaAgreement"
          v-if="activeTab2.includes('quotaAgreement')"
        >
          <span slot="label"><i class="el-icon-date"></i> 额度协议管理</span>

          <quotaAgreement
            :data="personalInfoData"
            ref="quotaAgreement"
          ></quotaAgreement>
        </el-tab-pane>

        <el-tab-pane
          label="结清证明申请"
          name="settlementCertificate"
          v-if="activeTab2.includes('settlementCertificate')"
        >
          <span slot="label"><i class="el-icon-date"></i> 结清证明申请</span>

          <settlementCertificate
            :data="personalInfoData"
            ref="settlementCertificate"
          ></settlementCertificate>
        </el-tab-pane>

        <el-tab-pane
          label="实时扣款查询"
          name="deductionQuery"
          v-if="activeTab2.includes('deductionQuery')"
        >
          <span slot="label"><i class="el-icon-date"></i> 实时扣款查询</span>

          <deductionQuery
            :data="personalInfoData"
            ref="deductionQuery"
          ></deductionQuery>
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>
<script>
import Axios from "axios";
import informationShow from "@/components/common/informationShow";
import searchInput from "@/components/common/CommonDate";
import ChildDropDown from "@/components/common/DropDownLoad";
import draggable from "vuedraggable";
import { queryLoss } from "@/api/bankBiz/loss/loss";
import customerInfo from "@/components/common/customerInfo.vue";
import repayPlan from "@/components/common/repayPlan";
import customerImageView from "@/components/common/customerImageView";
import overPayManage from "@/components/common/overPaymentManage.vue";
import quotaAgreement from "@/components/common/quotaAgreement.vue";
import settlementCertificate from "@/components/common/settlementCertificate.vue";
import deductionQuery from "@/components/common/deductionQuery.vue";
import proactiveRepayment from "@/components/common/proactiveRepayment.vue";
import { customerNoDesensitization } from "@/api/hubeixiaojin/HbUtils";
import {
  queryInfoCMIS100001,
  queryInfoCMIS100098,
  queryInfo0CMIS100001,
  queryLoanDetailsByIdNo,
} from "@/api/hubeixiaojin/queryInfo";

export default {
  components: {
    informationShow,
    searchInput,
    ChildDropDown,
    draggable,
    repayPlan,
    customerInfo,
    customerImageView,
    overPayManage,
    quotaAgreement,
    settlementCertificate,
    deductionQuery,
    proactiveRepayment,
  },
  data() {
    let _that = this;
    let validateBank = function (rule, value, callback) {
      const bankReg = /^\d{1,}$/;
      if (bankReg.test(value)) {
        // 账号
        if (value.indexOf("070667") != -1) {
          if (value.charAt(11) != "1") {
            callback(new Error("请输入对私账号！"));
          } else if (value.length != 22) {
            callback(new Error("请输入22位的对私账号！"));
          } else {
            if (_that.clickEventFlag) {
              _that.clickEventFlag = false;
              _that.accountData = [];
              _that.personalInfoData = [];
              _that.$store.commit("SET_PERSONALFLAG", false);
              _that.idCheckTxt = "身份验证未通过";
              _that.idPass = true;
              _that.allFn("bankNo");
            }
            _that.$refs["formPersonal"].clearValidate();
          }
        }
        // 卡号
        else if (
          value.indexOf("62311003") != -1 ||
          value.indexOf("623503001") != -1 ||
          value.indexOf("62299502") != -1 ||
          value.indexOf("62311005") != -1 ||
          value.indexOf("62311007") != -1 ||
          value.indexOf("62264802") != -1 ||
          value.indexOf("62311008") != -1 ||
          value.indexOf("62311006") != -1 ||
          value.indexOf("62264801") != -1 ||
          value.indexOf("62248800") != -1 ||
          value.indexOf("62299501") != -1 ||
          value.indexOf("62248802") != -1 ||
          value.indexOf("62248803") != -1 ||
          value.indexOf("62248810") != -1 ||
          value.indexOf("62248811") != -1 ||
          value.indexOf("62248820") != -1 ||
          value.indexOf("62248880") != -1 ||
          value.indexOf("62248888") != -1 ||
          value.indexOf("62264800") != -1 ||
          value.indexOf("62268811") != -1 ||
          value.indexOf("62268888") != -1 ||
          value.indexOf("62824899") != -1 ||
          value.indexOf("62248801") != -1 ||
          value.indexOf("62824866") != -1 ||
          value.indexOf("62311000") != -1 ||
          value.indexOf("62311001") != -1 ||
          value.indexOf("62311009") != -1 ||
          value.indexOf("62311002") != -1
        ) {
          if (value.length != 16) {
            callback(new Error("请输入16位的卡号！"));
          } else {
            if (_that.clickEventFlag) {
              _that.clickEventFlag = false;
              _that.accountData = [];
              _that.personalInfoData = [];
              _that.$store.commit("SET_PERSONALFLAG", false);
              _that.idCheckTxt = "身份验证未通过";
              _that.idPass = true;
              _that.allFn("bankNo");
            }
            _that.$refs["formPersonal"].clearValidate();
          }
        } else {
          callback(new Error("请输入正确的卡/账号！"));
        }
        callback();
      } else {
        callback(new Error("卡/账号必须为纯数字！"));
      }
    };
    //验证身份证号：
    let validateIdCard = function (rule, value, callback) {
      // 身份证
      let idcardReg =
        /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
      // 护照
      if ("17" == _that.objForm.idType) {
        idcardReg = /^\d{1,}$/;
      }
      if (idcardReg.test(value)) {
        if (_that.clickEventFlag) {
          _that.clickEventFlag = false;
          _that.accountData = [];
          _that.personalInfoData = [];
          _that.$store.commit("SET_PERSONALFLAG", false);
          _that.idCheckTxt = "身份验证未通过";
          _that.idPass = true;
          _that.allFn("cardNo");
        }
        _that.$refs["formPersonal"].clearValidate();
        callback();
      } else {
        callback(new Error("请输入正确的证件号码！"));
      }
    };
    //验证客户申请编号：
    const validateKhsqbh = function (rule, value, callback) {
      if (value === "") {
        callback("请输入客户申请编号");
      } else {
        callback();
      }
    };

    //验证手机号码：
    const validatePhone = function (rule, value, callback) {
      const phoneReg =
        /^1(3[0-9]|4[01456789]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/;
      if (phoneReg.test(value)) {
        // 手机号验证通过
        callback();
      } else {
        // 手机号验证未通过
        callback(new Error("请输入正确的手机号！"));
      }
    };

    return {
      activeTab: "shouye",
      activeTab2: [],
      clickEventFlag: false,
      listData: [],
      personalListInfoData: [],
      personalBankNo: "",
      checkFlag: false,
      objForm: {},
      optionFormData: {
        emptyBtn: false,
        submitBtn: false,
        menuPosition: "left",
        column: [
          //2024-04-12添加
          {
            label: "客户申请编号",
            labelWidth: "120", //  设置label的宽度
            prop: "khsqbh",
            //'type': 'search',
            appendClick: () => {
              this.clickEventFlag = true;
              this.$refs["formPersonal"].validateField("khsqbh");
            },
            mock: {
              type: "khsqbh",
            },
            //span: 12,
            // rules: [
            //   {
            //     required: true,
            //     message: "请输入客户申请编号",
            //     trigger: "blur"
            //   },
            //   {
            //     validator: validateKhsqbh,
            //     trigger: "blur"
            //   }
            // ],
            //style: "width:300px;",
            labelStyle: "text-align: right;",
          },
          {
            label: "证件号",
            prop: "idNo",
            //'type': 'search',
            labelWidth: "120",
            appendClick: () => {
              this.clickEventFlag = true;
              this.$refs["formPersonal"].validateField("idNo");
            },
            mock: {
              type: "idNo",
            },
            //span: 10,
            rules: [
              {
                required: true,
                message: "请输入证件号",
                trigger: "blur",
              },
              {
                validator: validateIdCard,
                trigger: "blur",
              },
            ],
            //style: "width:300px;",
            labelStyle: "text-right;",
          },
          {
            label: "  手机号码",
            labelWidth: "120",
            prop: "mobileNo",
            //'type': 'search',
            appendClick: () => {
              this.clickEventFlag = true;
              this.$refs["formPersonal"].validateField("mobileNo");
            },
            mock: {
              type: "mobileNo",
            },
            //span: 10,
            // rules: [
            //   {
            //     required: true,
            //     message: "请输入手机号码",
            //     trigger: "blur"
            //   },
            //   {
            //     validator: validatePhone,
            //     trigger: "blur"
            //   }
            // ],
            //style: "width:300px;"
          },
        ],
      },
      idCheckTxt: "身份验证未通过",
      idPass: true,
      personalInfoData: {
        applSeq: "-",
        custName: "-",
        idTyp: "-",
        idNo: " -",
        xb: "-",
        mobilephone: " -",
        liveAddr: "-",
        indivMarital: "-",
      },
      //personalInfoData: { 'applSeq': "10042023101611863394",'custName':'魏小军','idTyp':'身份证','idNo':'130625199901130014','xb':'10','mobilephone':'15921434490','liveAddr':'石桥一路梦工厂一创一楼','indivMarital':'未婚' },
      personalOption: {},
      defaultCustInfo: {
        applSeq: "--",
        custName: "--",
        idTyp: "--",
        idNo: "--",
        mobileNo: "-",
        idNo: "-",
        xb: "-",
        mobilephone: "-",
        liveAddr: "--",
        indivMarital: "--",
      },
      accountData: [],
      accountOption: {},
      // 判断三方验密AND进线验密标识
      callingStatusFlag: false,
      customerName: "",
      idNo: "",
      sqbh: "",
      total: 0,
      currentPage: 1,
    };
  },
  created() {
    this._setParamsModule();
    // if (this.$store.getters.GET_PERSONALFLAG || this.$store.getters.GET_LOSSFLAG) {
    //   this.initCustomerInfo()
    // }
    this.initCustomerInfo();
  },
  mounted() {
    console.log("router name is " + this.$route.name);
    /********************************** 小程序交互信令 ****************************************/
    let self = this;
    // 验密结果
    window.eventEmitter.$on("EventVerifyResult", (data) => {
      if (
        "01" == data.i_verifyflag &&
        ("06" == data.p_verifytype || "02" == data.p_verifytype)
      ) {
        self.$store.commit("SET_PERSONALFLAG", true);
        self.idCheckTxt = "身份验证通过";
        self.idPass = false;
        self.accountOption.accountList.resList[6].show = false;
        if ("06" == data.p_verifytype) {
          self.initCustomerInfo();
        }
      }
    });
    // 振铃进线初始化
    window.eventEmitter.$on("EventCallRecordChange", (data) => {
      self.activeTab2 = [];
      self.personalInfoData = {};
      self.accountData = [];
      self.personalListInfoData = [];
      self.personalBankNo = "";
      self.$store.commit("SET_PERSONALFLAG", false);
      self.$store.commit("SET_OFFLINESTATUS", false);
      self.$store.commit("SET_PERSONALCHECKFLAG", false);
      self.$store.commit("SET_GLOBALCARDNO", "");
      self.idCheckTxt = "身份验证未通过";
      self.idPass = true;

      console.log("界面初始化数据==", data.userData);
      self.objForm = {
        idNo: data.userData.idNo,
        // mobileNo: data.userData.userId,
      };

      if (self.objForm.idNo) {
        self.queryInfo();
      }

      self.initCustomerInfo();
    });
    //兼容预览外呼离线状态可查询
    window.eventEmitter.$on("EventAgentStatusChanged", () => {
      self.$store.commit("SET_OFFLINESTATUS", false);
    });
    // 挂机初始化
    window.eventEmitter.$on("EventInfoReset", () => {
      self.personalInfoData = {};
      self.objForm = {
        khsqbh: "",
        idNo: "",
        mobileNo: "",
      };
      self.accountData = [];
      self.personalListInfoData = [];
      self.personalBankNo = "";
      self.idCheckTxt = "身份验证未通过";
      self.idPass = true;
      self.checkFlag = false;
      self.$store.commit("SET_PERSONALCHECKFLAG", false);
      self.$store.commit("SET_GLOBALCARDNO", "");
    });
  },
  methods: {
    handleIconClick(tabName) {
      // console.log("tab切换", tabName);
      this.activeTab = tabName;
      // 检查 activeTab2 中是否已经包含 tabName
      if (!this.activeTab2.includes(tabName)) {
        this.activeTab2.push(tabName);
      }
    },

    onhome() {
      // console.log("点击tab首页");
      this.$router.push({ name: "personal" });
    },
    // 界面初始化获取客户信息
    initCustomerInfo() {
      let data = Constants.Model;
      if (data && data.userData) {
        if (
          "01" == data.userData.i_verifyflag &&
          ("06" == data.userData.p_verifytype ||
            "02" == data.userData.p_verifytype)
        ) {
          this.idCheckTxt = "身份验证通过";
          this.idPass = false;
          this.$store.commit("SET_PERSONALFLAG", true);
          this.accountOption.accountList.resList[6].show = false;
          if (
            "01" == data.userData.p_cert_type ||
            "02" == data.userData.p_cert_type
          ) {
            this.objForm.cardAccNumber = data.userData.p_cert_num;
            this.allFn("bankNo");
          } else if ("03" == data.userData.p_cert_type) {
            this.objForm.idNo = data.userData.p_cert_num;
            this.allFn("cardNo");
          }
        } else {
          if (data.userData.g_currAccNo) {
            this.objForm.cardAccNumber = data.userData.g_currAccNo;
            this.allFn("bankNo");
          }
        }
      } else {
        console.log("获取客户信息随路数据为空！");
      }
    },
    // 模块参数化配置
    _setParamsModule() {
      this.personalOption = window.personalOptions.moduleOption.personalOption;
      this.accountOption = window.personalOptions.moduleOption.accountOption;
      this.listData = window.personalOptions.routerQuery;
      console.log(
        "personal router query array is: " + JSON.stringify(this.listData)
      );
    },

    // 客户信息查询（废弃）
    _queryCustInfo(typeNo) {
      // 客户信息接口
      let customerNo = "";
      let customerParams = {
        namespace: "Personal",
        key: "personalInformationShow",
        query: {
          accountNo: "6231100088888421",
          idType: "",
          idNo: "",
        },
      };
      // 卡号
      if ("bankNo" == typeNo) {
        customerParams.query.accountNo = this.objForm.cardAccNumber;
        customerParams.query.idType = "";
        customerParams.query.idNo = "";
      }
      // 证件号
      else {
        customerParams.query.accountNo = "";
        customerParams.query.idType = this.objForm.idType;
        customerParams.query.idNo = this.objForm.idNum;
      }
      queryLoss(customerParams)
        .then((res) => {
          console.log(
            "response personalInfoData is: " + JSON.stringify(res.data.data)
          );
          // 无此客户
          if (!res.data.data) {
            this.personalInfoData = {};
            window.globalUiKit.notify("提示", res.data.message, "info");
            return;
          }
          // 清除验证标识
          if (!this.$store.getters.GET_PERSONALFLAG) {
            this.$store.commit("SET_PERSONALFLAG", false);
            this.idCheckTxt = "身份验证未通过";
            this.idPass = true;
          }
          this.personalInfoData = res.data.data;
          customerNo = this.personalInfoData.no;
          if (
            this.personalInfoData.no.indexOf("X") > -1 ||
            this.personalInfoData.no.indexOf("x") > -1
          ) {
            customerNo = this.personalInfoData.no
              .replace("X", "")
              .replace("x", "");
          }
          sessionStorage.setItem("customerNo", customerNo);
          sessionStorage.setItem(
            "customerIdType",
            this.personalInfoData.idType
          );
          sessionStorage.setItem("customerIdNo", this.personalInfoData.idNo);
          sessionStorage.setItem("customerPhone", this.personalInfoData.phone);
          saveTransCusInfo(
            this.personalInfoData.name,
            this.personalInfoData.idType,
            this.personalInfoData.idNo
          );
        })
        .catch((err) => {
          console.log(err);
        });
    },
    // 搜索框查询
    searchSubmitForm() {
      this.$message.success("当前数据" + JSON.stringify(this.objForm));
    },
    // 列表查询
    _searchList(typeNo) {
      let accountParams = {
        namespace: "Personal",
        key: "accountInfoData",
        query: {
          accountNo: "6231100088888421",
          idType: "",
          idNo: "",
        },
      };
      // 卡号
      if ("bankNo" == typeNo) {
        accountParams.query.accountNo = this.objForm.cardAccNumber;
        accountParams.query.idType = "";
        accountParams.query.idNo = "";
      }
      // 证件号
      else {
        accountParams.query.accountNo = "";
        accountParams.query.idType = this.objForm.idType;
        accountParams.query.idNo = this.objForm.idNum;
      }
      queryLoss(accountParams)
        .then((res) => {
          console.log(
            "response personal accountData is: " + JSON.stringify(res.data.data)
          );
          // 清除选中卡号
          this.checkFlag = false;
          this.$store.commit("SET_PERSONALCHECKFLAG", false);
          // 隐藏主账户
          this.accountOption.accountList.resList[6].show = true;
          this.accountData = res.data.data;
          if (!this.accountData) {
            window.globalUiKit.notify("提示", res.data.message, "info");
            return;
          }
          let bankNoList = "";
          for (let i = 0; i < this.accountData.length; i++) {
            bankNoList += this.accountData[i].no + ",";
          }
          bankNoList = bankNoList.substring(0, bankNoList.length - 1);
          sessionStorage.setItem("bankNoList", bankNoList);
        })
        .catch((err) => {
          console.log(err);
        });
    },
    // 选中列表项
    checkedListBn(data) {
      console.log("receive data is: " + data[0]);
      // 标记是否有选中的账号
      this.checkFlag = data[1];
      this.$store.commit("SET_PERSONALCHECKFLAG", data[1]);
      // 判断是否选中
      if (data[1]) {
        let index = data[0];
        this.personalListInfoData = [];
        this.personalListInfoData.push(this.accountData[index]);
        sessionStorage.setItem("accName", this.personalListInfoData[0].name);
        sessionStorage.setItem("bankNo", this.personalListInfoData[0].no);
        sessionStorage.setItem(
          "openBankName",
          this.personalListInfoData[0].openBank
        );
        this.personalBankNo = this.personalListInfoData[0].no;
        this.$store.commit("SET_GLOBALCARDNO", this.personalListInfoData[0].no);
        if (!this.personalBankNo) {
          window.globalUiKit.notify(
            "提示",
            "选中的账户信息没有卡号！",
            "error"
          );
        }
      } else {
        this.personalBankNo = "";
      }
    },
    // 电话验密
    verificationFn() {
      let self = this;
      if (!window.Settings.verifySwitch) {
        if (self.$store.getters.GET_OFFLINESTATUS) {
          window.globalUiKit.notify("提示", "离线状态不能验密！", "error");
          return;
        }
        if (!self.checkFlag) {
          window.globalUiKit.notify("提示", "请先选择一个卡号/账号！", "error");
          return;
        }
        if (!self.personalBankNo) {
          window.globalUiKit.notify(
            "提示",
            "选中的账户信息没有卡号，不能验密！",
            "error"
          );
          return;
        }
      } else {
        self.personalBankNo = "1234567890";
        self.$store.commit("SET_PERSONALFLAG", true);
      }
      window.globalUiKit.confirm(
        "提示",
        "是否要进行电话验密操作?",
        function () {
          let userdata = {
            // 私有部分，根据不同验证类型组合
            p_verifytype: "02", // 验密类型
            p_cert_type: "01", // 介质类型
            p_cert_num: self.personalBankNo || "", // 介质号码
            p_accno: "", // 对公客户号
            p_oper_id: "", // 对公操作员ID
            p_pass_type: "01", // 密码类型
            p_pass_operate: "01", // 交易密码操作
            p_biz: "00", // 业务操作
            // 公共部分
            r_function: "singletransfer",
            r_flag: "3",
            con_flag: "1",
          };
          globalUserData.verifyPass(userdata);
          if (window.Settings.verifySuccessSwitch) {
            self.$store.commit("SET_PERSONALFLAG", true);
            self.idCheckTxt = "身份验证通过";
            self.idPass = false;
            self.accountOption.accountList.resList[6].show = false;
          }
        }
      );
    },
    // 按钮搜索条件，请求方法集合
    allFn(typeNo) {
      // 离线状态不能操作
      console.log(this.$store.getters.GET_OFFLINESTATUS);
      if (this.$store.getters.GET_OFFLINESTATUS) {
        window.globalUiKit.notify("提示", "离线状态不能查询！", "error");
        return;
      }
      this._searchList(typeNo);
      this._queryCustInfo(typeNo);
    },

    //----------------------2024-04-15 添加：----------------------------------
    //客户基本资料 查询：
    queryInfo() {
      this.activeTab = "shouye";
      let self = this;
      sessionStorage.setItem("idNo", this.objForm.idNo);
      console.log("开始查询客户基本信息");
      this.activeTab2 = [];
      if (this.objForm.khsqbh && this.objForm.khsqbh.length > 0) {
        //走单条查询逻辑：
        console.log("单条申请流水号查询逻辑：");
        queryInfo0CMIS100001(this.objForm.khsqbh).then((res) => {
          console.log(res);
          if (res.retCode === "200") {
            console.log("200");
            self.personalInfoData = res.data;
            var lcApptIndivList = {};
            lcApptIndivList = res.data.lcApptIndivList; //申请人信息表
            if (Object.keys(lcApptIndivList).length > 0) {
              self.personalInfoData.xb = lcApptIndivList.lcApptIndiv.indivSex; //性别
              self.personalInfoData.liveAddr =
                lcApptIndivList.lcApptIndiv.liveAddr; //现住房地址
              self.personalInfoData.indivMarital =
                lcApptIndivList.lcApptIndiv.indivMarital; //婚姻状态
              var mobilephone = lcApptIndivList.lcApptIndiv.indivMobile; //手机号
              //self.personalInfoData.mobilephone = customerNoDesensitization(mobilephone)//脱敏后的移动电话
              self.personalInfoData.mobilephone = mobilephone; //移动电话
            }
          } else {
            console.log("单条申请流水查询失败1111");
            window.globalUiKit.notify("提示", "未查询到客户资料信息", "info");
          }
        });
        return;
      } else if (this.objForm.idNo && this.objForm.idNo.length > 0) {
        //多条查询逻辑
        console.log("多条申请流水号查询逻辑：");
        queryLoanDetailsByIdNo(this.objForm.idNo)
          .then((res) => {
            console.log("res:");
            console.log(res);
            if (res.retCode == "200") {
              console.log("查询成功,赋值personalInfoData");
              self.personalInfoData = res.data[0];
              var lcApptIndivList = {};
              lcApptIndivList = res.data[0].lcApptIndivList; //申请人信息表
              //console.log(lcApptIndivList.length)
              if (Object.keys(lcApptIndivList).length > 0) {
                self.personalInfoData.xb = lcApptIndivList.lcApptIndiv.indivSex; //性别
                self.personalInfoData.liveAddr =
                  lcApptIndivList.lcApptIndiv.liveAddr; //现住房地址
                self.personalInfoData.indivMarital =
                  lcApptIndivList.lcApptIndiv.indivMarital; //婚姻状态
                var mobilephone = lcApptIndivList.lcApptIndiv.indivMobile; //手机号
                //self.personalInfoData.mobilephone = customerNoDesensitization(mobilephone)//脱敏后的移动电话
                self.personalInfoData.mobilephone = mobilephone; //移动电话
              }

              // var indivMarital = '-'
              // if(hyzk=='10'){
              //   indivMarital = '未婚'
              // }else if(hyzk=='20'){
              //   indivMarital = '已婚'
              // }else if(hyzk=='40'){
              //   indivMarital = '离异'
              // }else if(hyzk=='50'){
              //   indivMarital = '丧偶'
              // }else if(hyzk=='90'){
              //   indivMarital = '其他'
              // }
              //self.personalInfoData.indivMarital = indivMarital

              //var zjlx = res.data.applLoanListDetails[0].idTyp//证件类型
              // var idTyp = '-'
              // var zjlx = self.personalInfoData.idTyp//证件类型
              // if(zjlx=='20'){
              //   idTyp = '身份证'
              // }else if(zjlx=='22'){
              //   idTyp = '护照'
              // }else if(zjlx=='00'){
              //   idTyp = '员工代码'
              // }else if(zjlx=='25'){
              //   idTyp = '军官证'
              // }else if(zjlx=='26'){
              //   idTyp = '士兵证'
              // }else if(zjlx=='2X'){
              //   idTyp = '其他证件'
              // }else if(zjlx=='30'){
              //   idTyp = '组织机构代码证'
              // }
              // self.personalInfoData.idTyp = idTyp
            } else {
              console.log("调用CMIS100001接口失败:");
              window.globalUiKit.notify("提示", "未查询到客户信息", "info");
              self.personalInfoData = self.defaultCustInfo;
            }
          })
          .catch((err) => {
            self.personalInfoData = self.defaultCustInfo;
            window.globalUiKit.notify("提示", "未查询到客户信息", "error");
            console.log("调用CMIS100001接口异常:");
            console.log(err);
          });
      } else {
        window.globalUiKit.notify("提示", "请输入客户申请编号或证件号", "info");
      }
    },

    //客户基本资料 重置：
    restAll() {
      const jsonpath = require("jsonpath-plus");
      console.log("重置客户基本资料");
      this.personalInfoData = {};
      this.objForm.khsqbh = "";
      this.objForm.idNo = "";
      this.objForm.mobileNo = "";
    },

    //跳转router路由
    goRouteList(name) {
      if (!this.verificationResult) {
        if (
          name === "transactionFlowQuery" ||
          name === "customeBuss" ||
          name === "loanData"
        ) {
          this.$router.push({ name });
          // if(!this.flag_smsorpassword){
          //   this.$router.push({ name })
          // }else{
          //   window.globalUiKit.notify('提示', '请先进行动态密码验证或短信验证', 'info')
          // }
        } else {
          this.$router.push({ name });
        }
      }
    },

    //切换Tab页：
    handleTabChange(nextName, oldName) {
      // console.log(sessionStorage);
      // console.log("切换前tab页:" + oldName);
      console.log("切换到tab页:" + nextName);
      const componentName_old = oldName;
      const componentName_new = nextName;
      if (componentName_old && componentName_new != "customerImageView") {
        this.$nextTick(() => {
          // console.log(this.$refs);
          // this.$refs[componentName_old].restAll(); // 调用子组件的重置数据的方法
          if (nextName == "shouye") {
            return;
          }

          this.$refs[componentName_new].queryInfo(this.objForm.idNo); // 调用子组件的查询数据的方法
        });
      }
    },

    //切换每页条数
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    //切换当前页
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
  },
  // 路由拦截
  beforeRouteEnter(to, from, next) {
    next((vm) => {
      console.log("personal bank no is: " + vm.personalBankNo);
      if (vm.personalBankNo) {
        sessionStorage.setItem("bankNo", vm.personalBankNo);
      } else {
        sessionStorage.setItem("bankNo", "");
      }
    });
  },
};
</script>
<style scoped>
.custInfo .el-col span,
.cardAndAccInfo .el-col span {
  line-height: 34px;
}

.bankNameSelect .el-select .el-input.is-focus .el-input__inner {
  border-color: #b50029 !important;
}

/*子模块区域*/
.inlineStyle {
  width: 100px;
  display: inline-block;
  text-align: center;
}

.inlineStyle span {
  text-align: center;
  display: block;
}

.sonArea img {
  width: 70px;
  height: 70px;
}

.el-dialog tr > th.el-table_1_column_1 > .cell {
  display: none;
}

/*超出省略*/
.wordEllipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  white-space: nowrap;
}

.bankContainer .el-form-item {
  margin-bottom: 6px;
}

.bankContainer ul li {
  float: none !important;
  text-align: left !important;
}

.topHeaderSearch span {
  height: 40px;
  line-height: 40px;
}

.searchInputStyle {
  color: #606266;
  font-weight: 700;
  line-height: 34px;
}

.verificationTips {
  width: 100%;
  height: 1px;
  text-align: right;
  position: relative;
}

.verificationTips span {
  position: absolute;
  right: 10px;
  top: 15px;
  z-index: 99;
}

::v-deep .el-col-xs-24 {
  width: 50%;
}

::v-deep .second-menu {
  background-color: #fff !important;
  border: #fff !important;
}
</style>
